Ext.define('component.proceeds.uploadFileWin', {
	extend : 'Ext.window.Window',
	callbackFun: function (record) {
		Ext.Msg.alert('提示', '回调函数未配置！');
	},
	initComponent : function() {
		
		// 格式化文件大小
		function formatFileSize(value, cellmeta,record){ 
			return Ext.util.Format.fileSize(value);
		}
		
		// 格式化进度条
		function formatProgressBar(value, cellmeta,record){ 
			var returnValue = '';
			if(record.data.status == '已完成'){
				if (Ext.isIE) {
					returnValue = '<div class="x-progress-wrap" style="height: 18px">'
							+ '<div class="x-progress-inner">'
							+ '<div style="width: 100%;" class="x-progress-bar x-progress-text">' + '100 %'
					'</div>' + '</div>' + '</div>';
				} else {
					returnValue = '<div class="x-progress-wrap" style="height: 18px">'
							+ '<div class="x-progress-inner">' + '<div id="progressBar_' + record.data.fileId
							+ '" style="width: 100%;" class="x-progress-bar">' + '</div>' + '<div id="progressText_'
							+ record.data.fileId
							+ '" style="width: 100%;" class="x-progress-text x-progress-text-back" />100 %</div>'
							'</div>' + '</div>';
				}
			}else{
				returnValue = '<div class="x-progress-wrap" style="height: 18px">' + '<div class="x-progress-inner">'
							+ '<div id="progressBar_' + record.data.fileId + '" style="width: 0%;" class="x-progress-bar">'
							+ '</div>' + '<div id="progressText_' + record.data.fileId
							+ '" style="width: 100%;" class="x-progress-text x-progress-text-back" />0 %</div>'
							'</div>' + '</div>';
			}
			return returnValue;
		}
		
		
	    var columns = [
			{id:'fileId',header: '文件ID', width: 50, sortable: true, dataIndex: 'fileId', css: 'vertical-align:middle;', hidden: true},
			{id:'status',header: '状态', width: 50, sortable: true, dataIndex: 'status', css: 'vertical-align:middle;'},
            {id:'fileName',header: '文件名', width: 150, sortable: true, dataIndex: 'fileName', css: 'vertical-align:middle;'},
            {id:'fileSize',header: '大小', width: 80, sortable: true, dataIndex: 'fileSize', align: 'right', css: 'vertical-align:middle;', renderer: formatFileSize},
            {id:'progress',header: '进度', width: 120, sortable: true, dataIndex: 'progress', css: 'vertical-align:middle;', renderer: formatProgressBar},
            {id:'fileTime',header: '剩余时间', width: 100, sortable: true, dataIndex: 'fileTime', css: 'vertical-align:middle;'},
            {id:'fileSpeed',header: '速度', width: 100, sortable: true, dataIndex: 'fileSpeed', css: 'vertical-align:middle;'}
		];
		
		// 文件上传数据源
		var uploadFileStore = new Ext.data.JsonStore({
		    root: 'datas',
		    totalProperty: 'results',
		    fields: ['fileName']
		});
		
		var uploadFileGrid = Ext.create('Ext.grid.Panel', {
		    region: 'center',
			border: false,
			columnLines: true,
			stateful: true,
		    autoScroll: 'auto',
		    clicksToEdit: 1,
		    height: 395,
	        store: uploadFileStore,
	        columns: columns,
	        columnLines: true,
	        tbar: [
        		{text:'添加',icon:jypath+'/resources/ExtJSicons/comment_add.png'},
        		{text:'删除',icon:jypath+'/resources/ExtJSicons/comment_delete.png'},
        		{text:'开始上传',icon:jypath+'/resources/ExtJSicons/bullet_arrow_up.png'}
	        ]
		});
		
		
		
		var defaultConfig = {
			title : '文件上传',
			plain: true,
			width: 680,
			height: 480,
			maximizable: false,
			resizable: false,
			layout:'border',
			items:[uploadFileGrid]
		};
		
		Ext.apply(this,defaultConfig);
		this.callParent();
	}
});

